﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SzCourt.Logic.BLL;
using SzCourt.Logic.NBL.DBEntities;

namespace SzCourt.WebSite.shenwu
{
    public partial class zxview : System.Web.UI.Page
    {
        private string _ID = string.Empty;
        private string _Title = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                getInfo();
            }
        }

        private void getInfo()
        {

            this._ID = string.IsNullOrEmpty(Request.QueryString["id"]) ? "" : Request.QueryString["id"];
            if (this._ID.Length <= 0)
            {
                Response.Redirect("/shenwu/zxgk.aspx");
            }



            CarryOut bll = new CarryOut();
            pCaseCarryOutDoc result = (pCaseCarryOutDoc)bll.GetCarryOutDoc(Convert.ToInt32(this._ID));

           
            if (result != null)
            {
                this.HDocLookedUp.InnerHtml = result.DocLookedUp;
                this.pCaseName.InnerHtml = result.CaseName;
                //result.CaseContent.Replace(" ", "&nbsp;").Replace("\n", "<br/>");
                System.Text.UTF8Encoding converter = new System.Text.UTF8Encoding();


               // Response.Clear();
                Response.ContentType = "application/msword";

                HttpContext.Current.Response.AppendHeader("Content-Disposition ",
                "attachment;filename= " + HttpUtility.UrlEncode(result.DocLookedUp).Trim());

                Response.ContentEncoding = System.Text.Encoding.Default;
                HttpContext.Current.Response.Charset = "UTF-8 ";
               
                //图片输出的类型有: image/GIF  image/JPEG
                Response.BinaryWrite(result.CaseContent);

               // this.WebContent.InnerHtml = converter.GetString(result.CaseContent);

                this._Title = result.CaseName;
            }
            SetPageInfo();
        }

        /// <summary>
        /// 写页面title,keyword,description
        /// </summary>
        /// <param name="mWord"></param>
        private void SetPageInfo()
        {
            //this.TabName.InnerHtml = this._Title;
            Page.Title = string.Format("{0}  - 深圳市中级人民法院", this._Title);


        }
    }
}